﻿//Ana Isabel Ibáñez García
// version 1: create the window with all its controls
// version 6: added attribute modifyMode, added the second constructor to modifyMode, btnAccept_Click

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UMLDesigner
{
    public partial class AttributesWindow : Form
    {
        bool modifyMode;

        public AttributesWindow()
        {
            InitializeComponent();
            modifyMode = false;
            listBoxAttibutes.DataSource = DataType.GetTypes();
            listBoxVisibility.DataSource = VisibilityType.GetTypes();
        }


        public AttributesWindow(AttributeData attr)
            : this()
        {
            modifyMode = true;
            textBoxAttributeName.Text = attr.GetName();
            listBoxAttibutes.Text = attr.GetAttrType();
            listBoxVisibility.Text = attr.GetVisibility();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (!modifyMode)
            {
                WindowsManager.AddAttributeToForm(textBoxAttributeName.Text, listBoxAttibutes.Text, listBoxVisibility.Text);
            }
            else
            {
                WindowsManager.ModifyAttribute(textBoxAttributeName.Text, listBoxAttibutes.Text, listBoxVisibility.Text);
            }
            Close();
        }
       
    }
}
